import { createStore } from 'vuex'
export default createStore({
    // 共享数据
    state:{
        // 存放websocket连接
        ws:null,
        // 存放用户个人信息
        userInfo:{
            userId:"",
            avatar:"",
            username:"",
            age:"",
            email:"",
            mobile:"",
            signature:"",
            account:"",
        },
    },
    // 更新state数据,同步跟新
    mutations:{
        updateUserInfo(state, userinfo){
            state.userInfo.userId = userinfo.uid
            state.userInfo.avatar = userinfo.avatar
            state.userInfo.username = userinfo.username
            state.userInfo.age = userinfo.age
            state.userInfo.email = userinfo.email
            state.userInfo.mobile = userinfo.mobile
            state.userInfo.signature = userinfo.signature
            state.userInfo.account = userinfo.accountName
        },
        updateWs(state, ws){
            state.ws = ws
        }
    },
    // 更新state数据,异步更新
    actions:{},
    // 模块化,每个模块中有自己的state,mutations,actions 
    modules:{
    }
})

